import { fromJS } from 'immutable';
import * as constants from './constants';

const defaultState = fromJS({
  totalDataAmount: [],
  orderTrendData: [],
  orderSortData: [],
  hotTagsData: {
    name: 'root',
    children: [
      { name: '考研', value: 560 },
      { name: '外语学习', value: 500 },
      { name: '课件', value: 150 },
      { name: '资格考试', value: 140 },
      { name: '成人教育', value: 115 },
      { name: '动漫', value: 95 },
      { name: '偶像', value: 90 },
      { name: '图片', value: 75 },
      { name: '视频', value: 98 },
      { name: '教学研究', value: 60 },
      { name: '影视', value: 45 },
      { name: '经管营销', value: 40 },
      { name: 'IT/计算机', value: 40 },
      { name: '人文社科', value: 35 },
      { name: '农林牧渔', value: 40 },
      { name: '医药卫生', value: 40 },
      { name: '自然科学', value: 40 },
      { name: '摄影', value: 30 },
      { name: '游戏', value: 28 },
      { name: '饮食', value: 16 },
    ], 
  }
});

export default (state = defaultState, action) => {
  switch(action.type) {
    case constants.GET_ADMINDASHBOARDDATA:
      // return state.set('totalDataAmount', fromJS(action.totalDataAmount));
      return state.merge({
        totalDataAmount: fromJS(action.totalDataAmount),
        orderTrendData: fromJS(action.orderTrendData),
        orderSortData: fromJS(action.orderSortData)
      });
    default:
      return state;
  }
}